package org.shay.springcloud.common;

import java.util.HashMap;

/**
 * @author shay
 */
public interface Constants {

	String APPLICATION_VERSION = "1.0.1";
	/**
	 * admin service
	 */
	String APP_NAME_ADMIN = "shay-admin";

	String APP_NAME_LOG = "shay-log";
	String APP_NAME_USER = "shay-user";
	String APP_NAME_AUTH = "shay-auth";
	String APP_NAME_SYSTEM = "shay-system";

	String MODE_DEV = "dev";

	String MODE_TEST = "test";

	String MODE_PROD = "prod";

	/**
	 * 代码部署于 linux 上，工作默认为 mac 和 Windows
	 */
	String OS_NAME_LINUX = "LINUX";

	HashMap<String, String> NACOS_ADDR = new HashMap<String, String>() {
		{
			put(MODE_DEV, "192.168.122.128:8848");
			put(MODE_TEST, "127.0.0.1:8848");
			put(MODE_PROD, "127.0.0.1:8848");
		}
	};
	String NACOS_NAMESPACE = "shay-spring";
	String NACOS_GROUP = "SHAY_SPRING";

	HashMap<String, String> SENTINEL_ADDR = new HashMap<String, String>() {
		{
			put(MODE_DEV, "192.168.122.128:8858");
			put(MODE_TEST, "127.0.0.1:8848");
			put(MODE_PROD, "127.0.0.1:8848");
		}
	};

	HashMap<String, String> ZIPKIN_ADDR = new HashMap<String, String>() {
		{
			put(MODE_DEV, "192.168.122.128:9411");
			put(MODE_TEST, "127.0.0.1:9411");
			put(MODE_PROD, "127.0.0.1:9411");
		}
	};

	String NACOS_CONFIG_GROUP = "DEFAULT_GROUP";

	String NACOS_CONFIG_PREFIX = "shay";

	String NACOS_GROUP_SUFFIX = "-group";

	String NACOS_CONFIG_FORMAT = "json";

	/**
	 * nacos addr
	 *
	 * @param mode 运模式
	 * @return String
	 */
	static String nacosAddr(String mode) {
		if (NACOS_ADDR.containsKey(mode)) {
			return NACOS_ADDR.get(mode);
		}
		return NACOS_ADDR.get(MODE_DEV);
	}

	/**
	 * sentinel addr
	 *
	 * @param mode 模式
	 * @return String
	 */
	static String sentinelAddr(String mode) {
		if (SENTINEL_ADDR.containsKey(mode)) {
			return SENTINEL_ADDR.get(mode);
		}
		return SENTINEL_ADDR.get(MODE_DEV);
	}

	/**
	 * zipkin addr
	 *
	 * @param mode 模式
	 * @return String
	 */
	static String zipkinAddr(String mode) {
		if (ZIPKIN_ADDR.containsKey(mode)) {
			return ZIPKIN_ADDR.get(mode);
		}
		return ZIPKIN_ADDR.get(MODE_DEV);
	}
}
